package com.example.demo.response;

import lombok.Data;
import lombok.extern.flogger.Flogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@Data
public class CustomRspBody<T> {
    private static final Log logger = LogFactory.getLog("CustomRspBody");
    private int code;
    private String info;
    private T data;

    public CustomRspBody(){
        this.code = RspCodeInfoEnum.Success.getCode();
        this.info = RspCodeInfoEnum.Success.getInfo();
        this.data = null;
    }
    public CustomRspBody(int code, String info, T data){
        this.code = code; this.info = info; this.data = data;
    }
    public CustomRspBody(RspCodeInfoEnum codeInfoEnum, T data){
        this.code = codeInfoEnum.getCode(); this.info = codeInfoEnum.getInfo(); this.data = data;
    }

    public static CustomRspBody success(){
        return new CustomRspBody();
    }

    public static <T> CustomRspBody success(T data){
        return new CustomRspBody(RspCodeInfoEnum.Success, data);
    }
}
